package action;


import java.util.Iterator;
import java.util.List;

import org.apache.struts2.ServletActionContext;
import org.hibernate.Session;

import po.*;

import bean.EmailBean;
import bo.HibernateSessionFactory;

import com.opensymphony.xwork2.ActionSupport;

public class EmailDeleteDeleted extends ActionSupport{
	private int ids[];
	
	public String execute(){
		
		
		if(ids==null){
			return "EmailDeletedM";	
		}else{
			

			Session session = HibernateSessionFactory.getSession();
			for(int i=0;i<ids.length;i++){
				Email e = new EmailDAO().findById(ids[i]);
				String a = e.getAcceptflag();
				String b = e.getSendflag();

				if(a.equalsIgnoreCase("3")){
					e.setAcceptflag("5");
				}
				if(b.equalsIgnoreCase("3")){
					e.setSendflag("5");
				}
			}	
			session.beginTransaction().commit();
				

			return "EmailDeletedM";
		}
		

		
	}

	public int[] getIds() {
		return ids;
	}

	public void setIds(int[] ids) {
		this.ids = ids;
	}
	
}
